<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>v-on的基本使用</title>
  </head>
  <body>
    <div id="app">
      <h3>{{counter}}</h3>
      <button v-on:click="counter++">+</button>
      <button v-on:click="counter--">-</button>
      <button v-on:click="add()">+</button>
      <button v-on:click="dec()">-</button>
      <br />
      <button @click="add">+</button>
      <button @click="dec">-</button>
    </div>

    <script src="../vue.js"></script>
    <script>
      const app = new Vue({
        el: "#app",
        data: {
          message: "hello",
          counter: 0,
        },
        methods: {
          add() {
            this.counter++;
          },
          dec() {
            this.counter--;
          },
        },
      });
    </script>
  </body>
</html>
